import 'package:cached_network_image/cached_network_image.dart';
import 'package:flutter/material.dart';
import 'package:flutter_shensu/common/style/AiSuColors.dart';

class MyPage extends StatefulWidget {
  _MyPageState createState() => _MyPageState();
}

class _MyPageState extends State<MyPage>
    with AutomaticKeepAliveClientMixin<MyPage> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        backgroundColor: Color(AiSuColors.primaryAiSuValue),
        title: new Text('个人详情页面'),
      ),
      body: layout(context),
    );
  }

  Widget layout(BuildContext context) {
    return new Column(
      crossAxisAlignment: CrossAxisAlignment.stretch,
      children: <Widget>[
        _getHeardView(),
        Container(
          color: Color(AiSuColors.primarySpeedValue),
          height: 3.0,
        ),
        _getItemsView(),
      ],
    );
  }

  Widget _getHeardView() {
    Widget heardView = new Container(
        decoration: BoxDecoration(
          gradient: LinearGradient(
              colors: [const Color(0xFF23233C), const Color(0xFF1F355C)],
              begin: Alignment.topCenter,
              end: Alignment.bottomCenter),
        ),
        height: 158.0,
        child: new Row(
          children: <Widget>[
            Container(
              margin: const EdgeInsets.fromLTRB(30, 0, 0, 0),
              width: 75.0,
              height: 75.0,
              decoration: BoxDecoration(
                  border: Border.all(color: Colors.white, width: 2),
                  image: DecorationImage(
                    image: new CachedNetworkImageProvider(
                        'https://img11.18183.com/ku18183/image/2018/12/22/34c562757e933438435747d8b0a31d4c.jpg'),
                    fit: BoxFit.cover,
                  ),
                  shape: BoxShape.circle),
            ),
            Padding(
              padding: new EdgeInsets.fromLTRB(15, 0, 0, 0),
            ),
            Expanded(
              child: Column(
                crossAxisAlignment: CrossAxisAlignment.start,
                mainAxisAlignment: MainAxisAlignment.center,
                children: <Widget>[
                  new Container(
                    padding: const EdgeInsets.only(bottom: 8.0),
                    child: new Text(
                      '登录神速',
                      style: new TextStyle(
                          fontSize: 24.0,
                          fontWeight: FontWeight.bold,
                          color: Colors.white),
                    ),
                  ),
                  new Text(
                    '体验超快感',
                    style: new TextStyle(
                      color: Colors.white70,
                      fontSize: 16.0,
                    ),
                  ),
                ],
              ),
            ),
          ],
        ));

    return heardView;
  }

  Widget _getItemsView() {
    return Column(
      children: <Widget>[
        ListTile(
          leading: Icon(Icons.message),
          title: Text('消息'),
          trailing: Icon(Icons.chevron_right),
        ),
        Divider(
          indent: 50,
        ),
        ListTile(
          leading: Icon(Icons.feedback),
          title: Text('问题反馈'),
          trailing: Icon(Icons.chevron_right),
        ),
        Divider(
          indent: 50,
        ),
        ListTile(
          leading: Icon(Icons.event_note),
          title: Text('问题百科'),
          trailing: Icon(Icons.chevron_right),
        ),
        Divider(
          indent: 50,
        ),
        ListTile(
          leading: Icon(Icons.settings),
          title: Text('设置'),
          trailing: Icon(Icons.chevron_right),
        ),
        Divider(
          indent: 50,
        ),
      ],
    );
  }

  @override
  bool get wantKeepAlive => true;
}
